package scantask.containers;

import scantask.containers.exceptions.InvalidCoordinateValueException;

public class Coordinate {
	
	public static final double MIN_X = -180.0;
	public static final double MAX_X = 180.0;
	public static final double MIN_Y = -90.0;
	public static final double MAX_Y = 90.0;
	
	private double _x;
	private double _y;
	
	public Coordinate(double x, double y) throws InvalidCoordinateValueException {
		if ((x < MIN_X) || (x > MAX_X) || (y < MIN_Y) || (y > MAX_Y)) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Failed construct new Coordinate illegale x or y value");
			scantask.client.utilities.logging.SingletonLogger.getLogger().warning("Failed construct new Coordinate illegale x or y value");
			throw new InvalidCoordinateValueException();
		}
		this._x = x;
		this._y = y;
	}
	
	public double getX() {
		return this._x;
	}
	
	public double getY() {
		return this._y;
	}
	
	public void setX(int x) throws InvalidCoordinateValueException {
		if ((x < MIN_X) || (x > MAX_X)) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Failed set Coordinate x value");
			scantask.client.utilities.logging.SingletonLogger.getLogger().warning("Failed set Coordinate x value");
			throw new InvalidCoordinateValueException();
		}
		this._x = x;
	}
	
	public void setY(int y) throws InvalidCoordinateValueException {
		if ((y < MIN_Y) || (y > MAX_Y)) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Failed set Coordinate y value");
			scantask.client.utilities.logging.SingletonLogger.getLogger().warning("Failed set Coordinate y value");
			throw new InvalidCoordinateValueException();
		}
		this._y = y;
	}

}
